﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace sushu
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        int a = 0;
        int b = 0;
        int[] m =new int [10000];
        private void high_TextChanged(object sender, EventArgs e)
        {
            TextBox text = sender as TextBox;
            if (text.Text == "") 
            {
                a = 0;
                warn.Text = "你还未输入上限";
            }
            else a = int.Parse(text.Text);
            if (a >= 1000 && text.Text != "") warn.Text = "上限不合理";
            else if (a>0) warn.Text = "";
        }


        private void low_TextChanged(object sender, EventArgs e)
        {
            TextBox text = sender as TextBox;
            if (text.Text == "")
            {
                b = 0;
                warn.Text = "你还未输入下限";
            }
            else b = int.Parse(text.Text);
            if (b <= 1&& text.Text != "") warn.Text = "下限不合理";
            else if (b > 1) warn.Text = "";
        }
            private void button1_Click(object sender, EventArgs e)
        {
            int i;
            int j = 1;
            suShu.Text = "";
            if (a <= b)
            {
                warn.Text = "上下限输入错误";
            }
            else
            {
                if (b >= 2)
                {
                    for (i = b; i <= a; i++)
                    {
                        int x = 1;
                        for (int n = 2; n < i; n++)
                        {
                            if (i % n == 0)
                            {
                                x = 0;
                            }
                        }
                        if (x == 1)
                        {
                            //i = m[j];
                            j++;
                            this.suShu.Text = this.suShu.Text + " " + i;
                        }

                    }
                }
            }
            
            
        }

        private void warn_Click(object sender, EventArgs e)
        {

        }
    }
}
